package L1;

import java.util.ArrayList;

class Fruit{
	private String name;

	public Fruit(String name) {
		super();
		this.name = name;
	}

	@Override
	public String toString() {
		return super.toString()+"name = " + name ;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Fruit other = (Fruit) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equalsIgnoreCase(other.name))
			return false;
		return true;
	}
}

public class l02 {
    public static void main(String[] args) {
    	ArrayList<Fruit> fruitList = new ArrayList<Fruit>();
    	Fruit[] f = new Fruit[4];
    	 f[0] = new Fruit("cheng");
         f[1] = new Fruit("HUIQING");
         f[2] = new Fruit("CHENG");
         f[3] = new Fruit("huiqing");
         for(int i=0;i<f.length;i++){
             if(fruitList.contains(f[i])==false)
                 fruitList.add(f[i]);
         }
         for(int i=0;i<fruitList.size();i++)
             System.out.println(fruitList.get(i));

    }
}

/*
 * return "width="+this.width+",length="+this.length
 
public String toString(){
	  company = new Company();
	  
	  return super.toString()+"-"+company.toString()+"-"+salary;
	}
	
	
	
	 int n=Integer.parseInt(sc.next());
			String[] b= new String[n];
			for (int i = 0; i < n; i++) {
				switch(sc.next()){
				case "c":
					Computer C = new Computer();
					b[i] = C.toString();
					break;
				case "d":
					Double D = new Double(sc.next());
					b[i] = D.toString();
					break;
				case "i":
					Integer I = new Integer(sc.next());
					b[i] = I.toString();
					break;
				case "s":
					String S = new String(sc.next());
					b[i] = S;
					break;
				default:
					b[i] = "null";
					break;
					
				}
			}
			for (int i = n-1; i >= 0; i--) {
				if(!b[i].equals("null"))
					System.out.println(b[i]);
				
			}




	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company))
			return false;
		DecimalFormat df = new DecimalFormat("#.##");
		String a = df.format(this.salary);
		double a1 = Double.parseDouble(a);
		String b = df.format(other.salary);
		double b1 = Double.parseDouble(b);
		if (a1 != b1)
			return false;
		return true;
	}
	
	
	
 */



